package com.test.application.designPatterns.singleton.demo4;

/**
 * 描述: 单例模式: 双重检查方式
 * 作者: yanruizhi
 * 时间: 2024/9/18 17:24
 */
public class DoubleCheck {
    private DoubleCheck() {
    }

    private volatile static DoubleCheck instance;

    public static DoubleCheck getInstance() {
        if (instance == null) {
            synchronized (DoubleCheck.class) {
                if (instance == null) {
                    instance = new DoubleCheck();
                }
            }
        }
        return instance;
    }
}
